/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.webevo.gui.panels.mapper;

import java.io.FileNotFoundException;
import java.io.IOException;
import javax.swing.JOptionPane;
import org.webevo.gui.controllers.ControllerUI_ThresholdCalculator;

/**
 *
 * @author Djordje
 */
public class PanelCalculateThreshold extends javax.swing.JPanel {
    private ControllerUI_ThresholdCalculator controller;
    
    /**
     * Creates new form PanelCalculateThreshold
     */
    public PanelCalculateThreshold() {
        initComponents();
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        btnChooseDataset = new javax.swing.JButton();
        txtFieldDatasetFile = new javax.swing.JTextField();
        btnCalculateThreshold = new javax.swing.JButton();

        setPreferredSize(new java.awt.Dimension(493, 106));

        btnChooseDataset.setText("Choose Dataset");
        btnChooseDataset.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnChooseDatasetActionPerformed(evt);
            }
        });

        txtFieldDatasetFile.setText("No Dataset Chosen");

        btnCalculateThreshold.setText("Calculate Thresholds");
        btnCalculateThreshold.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnCalculateThresholdActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(txtFieldDatasetFile, javax.swing.GroupLayout.DEFAULT_SIZE, 346, Short.MAX_VALUE)
                        .addGap(18, 18, 18)
                        .addComponent(btnChooseDataset))
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(btnCalculateThreshold)
                        .addGap(0, 0, Short.MAX_VALUE)))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(btnChooseDataset)
                    .addComponent(txtFieldDatasetFile, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(38, 38, 38)
                .addComponent(btnCalculateThreshold)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
    }// </editor-fold>//GEN-END:initComponents

    private void btnChooseDatasetActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnChooseDatasetActionPerformed
        controller.getFileChooser();
    }//GEN-LAST:event_btnChooseDatasetActionPerformed

    private void btnCalculateThresholdActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCalculateThresholdActionPerformed
        try {
            controller.calculateThreshold();
        } catch (FileNotFoundException ex) {
            JOptionPane.showMessageDialog(this, ex);
        } catch (IOException | ClassNotFoundException ex) {
            JOptionPane.showMessageDialog(this, ex);
        }
    }//GEN-LAST:event_btnCalculateThresholdActionPerformed

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btnCalculateThreshold;
    private javax.swing.JButton btnChooseDataset;
    private javax.swing.JTextField txtFieldDatasetFile;
    // End of variables declaration//GEN-END:variables

    /**
     * @return the btnCalculateThreshold
     */
    public javax.swing.JButton getBtnCalculateThreshold() {
        return btnCalculateThreshold;
    }

    /**
     * @param btnCalculateThreshold the btnCalculateThreshold to set
     */
    public void setBtnCalculateThreshold(javax.swing.JButton btnCalculateThreshold) {
        this.btnCalculateThreshold = btnCalculateThreshold;
    }

    /**
     * @return the btnChooseDataset
     */
    public javax.swing.JButton getBtnChooseDataset() {
        return btnChooseDataset;
    }

    /**
     * @param btnChooseDataset the btnChooseDataset to set
     */
    public void setBtnChooseDataset(javax.swing.JButton btnChooseDataset) {
        this.btnChooseDataset = btnChooseDataset;
    }

    /**
     * @return the txtFieldDatasetFile
     */
    public javax.swing.JTextField getTxtFieldDatasetFile() {
        return txtFieldDatasetFile;
    }

    /**
     * @param txtFieldDatasetFile the txtFieldDatasetFile to set
     */
    public void setTxtFieldDatasetFile(javax.swing.JTextField txtFieldDatasetFile) {
        this.txtFieldDatasetFile = txtFieldDatasetFile;
    }

    /**
     * @return the controller
     */
    public ControllerUI_ThresholdCalculator getController() {
        return controller;
    }

    /**
     * @param controller the controller to set
     */
    public void setController(ControllerUI_ThresholdCalculator controller) {
        this.controller = controller;
    }
    
    
}
